<?php

class comment extends Admin {

    private $limit = 15;
    private $name = '评论';

    public function __construct() {
        parent::__construct();
        $this->model->table = 'comment';
    }

    public function index( $c ) {
        $where = null;
        if ( isset( $_GET[ 'view' ] ) ) $where = array( 'view', R( 'view' ) );

        $result = $this->Pager( $this->limit )->findAll( $where, 'status asc, id desc' );
        include $this->display( $c );
    }

    // 审核评论
    public function verify( $c ) {
        if ( !$in_id = R( 'in_id' ) ) {
            $this->error();
        }

        $this->model->update( "id in ({$in_id}) ", array( 'status' => 1 ) );

        $this->success( "审核评论成功!" );
    }

    // 批量删除评论
    public function del( $c ) {
        if ( !$in_id = R( 'in_id' ) ) {
            $this->error();
        }

        $this->model->delete( "id in ({$in_id}) " );
        $this->success( "删除评论成功!" );
    }
}